<?php
/**
 *
 *
 */
namespace app\admin\controller;

use think\Controller;
use think\Db;
class Comment extends Common
{
    public function index()
    {
    	$id = input('id');
        $this->assign('id', $id);
        return view();
    }
    public function edit()
    {
        $id = input('id');
        $model = input('model');
        $this->assign('id', $id);
        $this->assign('model', $model);
        $c = Db::name('comment')->where('id', input('id'))->find();
        $this->assign('c', $c);
        return view();
    }
    //更新
    public function update()
    {
        $id = input('id');
        $data = $this->request->post();
        $data['time'] = time();
        if (Db::name('comment')->where('id', $id)->data($data)->update($data)) {
            $this->success('更新成功');
        } else {
            $this->error('更新失败');
        }
    }
//批量删除

    public function delss()
    {
        $id = input('id');
        //输出模型
        $params = input('post.');
        $ids = implode(',', $params['ids']);
        $result =  Db::name('comment')->delete($ids);
        if ($result) {
            return json(array('code' => 200, 'msg' => '批量删除成功'));
        } else {
            return json(array('code' => 0, 'msg' => '批量删除失败'));
        }
    }
}